package com.dognessnetwork.operation.dognecklace.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import com.dognessnetwork.operation.baseservice.DeviceInfoService;
import com.dognessnetwork.operation.dognecklace.domain.DeviceInfo;
import com.dognessnetwork.operation.dognecklace.dto.Response;
import com.dognessnetwork.operation.dognecklace.repository.DeviceInfoRepository;

@Service
public class DeviceInfoServiceImpl implements DeviceInfoService {
	
	private @Autowired DeviceInfoRepository deviceInfoRepostory;

	@Override
	public Response save(DeviceInfo deviceInfo) {
		if (StringUtils.isEmpty(deviceInfo)) {
			return Response.FAILURE;
		}
		DeviceInfo DeviceInfo = deviceInfoRepostory.save(deviceInfo);
		Response response = Response.SUCCESS(DeviceInfo);
		return response;
	}

	@Override
	public void deleteById(Long id) {
		
		deviceInfoRepostory.deleteById(id);
	}

	@Override
	public Response findById(Long id) {
		if (StringUtils.isEmpty(id)) {
			return Response.FAILURE;
		}
		DeviceInfo DeviceInfo = deviceInfoRepostory.findById(id).get();
		Response response = Response.SUCCESS(DeviceInfo);
		return response;
	}

}
